//
//  NewHomeNetwork.m
//  Shengzhuli
//
//  Created by FXGuo on 2018/1/24.
//  Copyright © 2018年 kamangkeji. All rights reserved.
//

#import "NewHomeNetwork.h"
#import "GFXNetworkHandle.h"
#import "BannerModel.h"
#import "ClubActivityListModel.h"
#import "NewMapModel.h"
#import "TicketModel.h"
#import "SpecialModel.h"
#import "HomeCommendModel.h"

NSString * const ClubList = @"club/list";//俱乐部列表
NSString * const ClubDetail = @"club/getClub";//俱乐部详情
NSString * const BannerList = @"banner/list";//banner
NSString * const ClubActivityList = @"club/activityList";//俱乐部活动列表 日历
NSString * const BaseList = @"club/baseList";//基地列表
NSString * const TicketList = @"auth/user/ticket";//券列表
NSString * const SpecialList = @"club/commodityList";//特色服务列表
NSString * const BaseSingleCreate = @"auth/ticketOrder/create";//基地订单生成
NSString * const ValibleTicker = @"auth/club/ticket";//用户可用券


NSString * const HomeCommend = @"headRecommend/list";//首页推荐

@implementation NewHomeNetwork

+ (void)getClubListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:ClubList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ClubModel *model = [ClubModel objectWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
+ (void)getClubDetailWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,ClubModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:ClubDetail params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            ClubModel *model = [ClubModel objectWithDict:json[@"result"]];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}
+ (void)getBannerListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:BannerList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                BannerModel *model = [BannerModel bannerWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getClubActivityListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:ClubActivityList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                ClubActivityListModel *model = [ClubActivityListModel objectWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getBaseListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:BaseList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                NewMapModel *model = [NewMapModel objectWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getTicketListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:TicketList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                TicketModel *model = [TicketModel objectWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getSpecialListWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *lists))response
{
    [[GFXNetworkHandle shareHandle]post:SpecialList params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                SpecialModel *model = [SpecialModel objectWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getCreateBaseSingleWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,SingleCreateModel *model))response
{
    [[GFXNetworkHandle shareHandle]post:BaseSingleCreate params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            SingleCreateModel *model = [SingleCreateModel objectWithDict:json[@"result"]];
            [sources addObject:model];
            response(YES,json[@"message"],model);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];

}

+ (void)getBaseValibleTicketWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *tickets))response
{
    [[GFXNetworkHandle shareHandle]post:ValibleTicker params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                TicketModel *model = [TicketModel objectWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

+ (void)getHomeCommendWithParame:(NSDictionary *)parames response:(void (^)(BOOL success,NSString *msg,NSArray *sources))response
{
    [[GFXNetworkHandle shareHandle]post:HomeCommend params:parames success:^(id json) {
        if ([json[@"status"] isEqualToString:SuccessStatus]) {
            NSMutableArray *sources = [NSMutableArray array];
            for (NSDictionary *dict in json[@"result"]) {
                HomeCommendModel *model = [HomeCommendModel objectWithDict:dict];
                [sources addObject:model];
            }
            response(YES,json[@"message"],sources);
        }else{
            response(NO,json[@"message"],nil);
        }
    } failure:^(NSError *error) {
        response(NO,NetworkError,nil);
    }];
}

@end
